'''
Created on Dec 7, 2011

@author: ibrahimelfar
'''

import django.template
from listen.environments import eclipse


class Eclipse:
    class HtmlTemplate(eclipse.Template):
        language = 'html'
        context = 'html_all'
        steps = {'naturally speaking': [('key', 'Ctrl + Space'),
                                        ('key', 'Ctrl + Space'),
                                        ('text', '{{name}}'),
                                        ('key', 'Enter'),]}
        
        def __init__(self, name, content, utterances):
            eclipse.Template.__init__(self, self.language, self.context, name, content, utterances, self.steps)

    templates = [HtmlTemplate(name = 'create-tag',
                 content = '<${tag}></$tag>',
                 utterances = ['create tag', 'new tag'],
                 )]

    class HtmlPattern(eclipse.SnippetPattern):
        contexts = dict(html = ['html_all'])
        
        def __init__(self, name, content):
            eclipse.SnippetPattern.__init__(self, self.contexts, name, content)

    class MultipleLineNoSelectionPattern(HtmlPattern):
        name = 'create-{{tag}}-tag'
        content = '''
        <{{tag}}>
            ${cursor}
        </{{tag}}>
        '''

        utterances = {'en-us': ['create {{translation[tag]}}',
                                'new {{translation[tag]}}']}
        
        def __init__(self):
            Eclipse.HtmlPattern.__init__(self, self.name, self.content)
            
    class MultipleLineWithSelectionPattern(HtmlPattern):
        name = 'mark-as-{{tag}}'
        content = '''
        <{{tag}}>
            ${text}
        </{{tag}}>
        ${cursor}
        '''
        
        def __init__(self):
            Eclipse.HtmlPattern.__init__(self, self.name, self.content)

    class SingleLineNoSelectionPattern(HtmlPattern):
        name = 'create-{{tag}}-tag'
        content = '<{{tag}}>${cursor}</{{tag}}>'

        def __init__(self):
            Eclipse.HtmlPattern.__init__(self, self.name, self.content)
            
    class SingleLineWithSelectionPattern(HtmlPattern):
        name = 'mark-as-{{tag}}'
        content = '<{{tag}}>${text}</{{tag}}>${cursor}'
        
        def __init__(self):
            Eclipse.HtmlPattern.__init__(self, self.name, self.content)

class VoiceConfiguration:
    utterances = []
    steps = []
    application = ''
    
class EclipseVoiceConfiguration:
    utternances = ['en-us']
    steps = {'ns': [Key(''), Text(''), Key('')]}
    steps = ['ctrl space, ctrl space, {{template.name}}']
    e = Eclipse.SingleLineNoSelectionPattern()
    
#configurations = [
#dict(utterances = ['create <tag>', 'new <tag>'],
#     eclipse = dict(pattern = Eclipse.SingleLineNoSelectionPattern,
#                    )
#(['create <tag>', 'new <tag>'], Eclipse.MultipleLineNoSelectionPattern)
#]